<?php

namespace App\Http\Requests\customer;

use App\Http\ValidateResult;
use Illuminate\Support\Facades\Validator;

trait TrajectoryRequest
{
    public static function add_check(array $params): ValidateResult {
        $validator = Validator::make($params, [
//            'id' => 'required',
            'node_id' => 'required',
            'time' => 'required',
            'unit' => 'required'
        ], [
            'node_id.required' => '请选择节点',
            'time.required' => '请填写时长',
            'unit.required' => '请选择时长单位',
        ]);

        if ($validator->fails()) {
            return ValidateResult::error($validator->errors()->first());
        }
        return ValidateResult::correct();
    }

}
